<template>
  <div class="content-div">
    <img class="headImg" :src="dataInfo.hospital_picture" alt="" style="height:150px;">
    <div class="base-info-box">
      <div class="name-box">{{dataInfo.hospital_name}}</div>
      <div class="time-box">{{'服务时间：' + dataInfo.hospital_time}}</div>
      <div class="address-box">
        <van-icon name="location" />
        <span>{{dataInfo.address}}</span>
      </div>
    </div>
    <div class="base-info-box">
      <div class="detail-head">
        <div></div>
        <span>医院简介</span>
      </div>
      <div ref="detalBox" class="detail-box" :style="{'height': isShowAll ? 'auto' : '300px'}">
        <div ref="detalBox" :style="{'padding-bottom': isShowAll ? '60px' : '0px'}">&emsp;&emsp;{{dataInfo.brief_introduction}}</div>
        <div @click="isShowAll=!isShowAll" :style="{'box-shadow': isShowAll ? 'unset' : '0 -20px 30px 20px #FFFFFF'}" class="show-more" v-if="showMore">
          <span>{{isShowAll ? '收起' : '展开阅读全文'}}</span>
          <van-icon v-if="isShowAll" name="arrow-up" />
          <van-icon v-else name="arrow-down" />
        </div>
      </div>
    </div>
    <div class="item-list-box">
      <div class="detail-head">
        <div></div>
        <span>服务项目</span>
      </div>
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getService">
        <div @click="$router.push(`/productDetail?give_service_id=${item.give_service_id}&&hospital_id=${hospital_id}&&hospital_name=${dataInfo.hospital_name}&&payable_amount=${item.give_service_price}&&give_service_type=${item.give_service_type}`)" class="list-item-box3" v-for="(item, index) in itemList" :key="index">
          <div class="list-head-box">
            <img :src="item.give_service_picture" alt="" srcset="">
            <div class="list-name-box">
              <span class="list-name">{{item.give_service_name}}</span>
              <div class="list-money-box">
                <span style="color: #FF0000;font-weight: bold;">￥<span class="money-text">{{item.give_service_price}}</span></span>
                <span class="yy-btn">立即预约</span>
              </div>
            </div>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>
<script>
import { getHospital, findGiveServiceList } from '@/api/medical.js'
export default {
  name: 'index',
  data () {
    return {
      loading: false,
      finished: false,
      isShowAll: true,
      showMore: false,
      hospital_id: '',
      dataInfo: {},
      itemList: [],
      hospital_name: ''
    }
  },
  created () {},
  methods: {
    getDetailInfo () {
      getHospital({
        hospital_id: this.hospital_id
      }).then(res => {
        if (res.data.errcode === 0) {
          this.dataInfo = res.data.data
          this.$nextTick(() => {
            if (this.$refs.detalBox.clientHeight > 300) {
              this.showMore = true
              this.isShowAll = false
            }
          })
        }
      })
    },
    getService () {
      findGiveServiceList({
        hospital_id: this.hospital_id
      }).then(res => {
        if (res.data.errcode === 0) {
          this.itemList = res.data.data
          this.loading = false
          this.finished = true
        }
      })
    }
  },
  mounted () {
    this.hospital_id = this.$route.query.id
    this.getDetailInfo()
  }
}
</script>

<style scoped lang="less">
  .content-div{
    padding: 10px;
    font-size: 12px;
    background-color: #f8f8f8;
    height: auto;
    min-height: 100%;
    .headImg{
      width: 100%;
      height: 150px;
      // object-fit: contain;
      margin-bottom: 6px;
    }
    .base-info-box{
      background-color: #FFFFFF;
      width: 300px;
      // margin-left: 10px;
      padding: 10px;
      box-sizing: border-box;
      border-radius: 6px;
      margin-bottom: 10px;
      .name-box{
        font-size: 14px;
        padding-bottom: 2px;
        font-weight: bold;
      }
      .time-box{
        color: #999999;
        padding-bottom: 2px;
      }
      .address-box{
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        i{
          color: #1989fa;
          margin-right: 4px;
        }
        span{
          flex: 1;
          font-size: 10px;
        }
      }
      .detail-head{
        position: relative;
        margin-bottom: 10px;
        div{
          position: absolute;
          background-color: #1989fa;
          width: 30px;
          // bottom: 2px;
          bottom: 0px; // 2024-01-02 评审说横线距离文字过近进行修改
          left: 9px;
          box-shadow: 0 0 1px 1px #1989fa;
        }
        span{
          position: relative;
          z-index: 1;
        }
      }
      .detail-box{
        line-height: 1.4;
        overflow: hidden;
        position: relative;
        .show-more{
          position: absolute;
          bottom: 0;
          background-color: #FFFFFF;
          height: 30px;
          left: 0;
          width: 100%;
          text-align: center;
          color: #1989fa;
          line-height: 30px;
          span{
            padding-right: 6px;
          }
        }
      }
    }
    .item-list-box{
      box-sizing: border-box;
      // padding: 0 10px 10px;
      .detail-head{
        position: relative;
        margin-bottom: 10px;
        div{
          position: absolute;
          background-color: #1989fa;
          width: 30px;
          // bottom: 2px;
          bottom: 0px; // 2024-01-02 评审说横线距离文字过近进行修改
          left: 9px;
          box-shadow: 0 0 1px 1px #1989fa;
        }
        span{
          position: relative;
          z-index: 1;
        }
      }
      .list-item-box3{
        margin-bottom: 10px;
        border-radius: 5px;
        border: 1px solid #eeeeee;
        background-color: #FFFFFF;
        box-sizing: border-box;
        padding: 10px;
        box-shadow: 0px 0px 10px #eeeeee;
        .list-head-box{
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: flex-start;
          height: 60px;
          .list-name-box{
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: flex-start;
            height: 100%;
            width: calc(100% - 70px);
            .list-name{
              overflow: hidden;
              text-overflow: ellipsis;
              word-break: break-all;
              white-space: nowrap;
              width: 100%;
            }
            .list-money-box{
              width: 100%;
              display: flex;
              flex-direction: row;
              justify-content: space-between;
              align-items: center;
              font-size: 10px;
              .money-text{
                font-size: 12px;
              }
              .yy-btn{
                color: #FFFFFF;
                padding: 2px 10px;
                height: 16px;
                line-height: 16px;
                border-radius: 10px;
                background-color: #1989fa;
              }
            }
          }
          img{
            width: 60px;
            height: 60px;
            margin-right: 10px;
          }
        }
      }
    }
  }
</style>
